<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/meta.jsp"%>
<title>使用单位管理</title>
</head>
<body>
	<%@include file="/common/header.jsp" %>
	
	<table cellpadding="0" cellspacing="0" border="0" align="center" width="640" style="margin: 10px auto;font-size: 14px;">
		<tr>
			<td width="120" height="40" align="right">
				<label>企业名称：</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="sydwQymc" style="width: 200px; height:20px;border: solid 1px #ccc;"/>
			</td>
			<td width="120" height="40" align="right">
				<label>组织机构代码：</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="sydwZzjgdm" style="width: 200px; height:20px;border: solid 1px #ccc;"/>
			</td>
		</tr>
		<tr>
			<td height="40" align="right">
				<label>所属辖区：</label>
			</td>
			<td align="left" height="40">
				<input id="xzqhName" readonly="readonly" onclick="showXzqh(this)" style="width: 200px; height:20px;border: solid 1px #ccc;" />
			</td>
			<td align="right" height="40">
				<label>所属网格：</label>
			</td>
			<td align="left" height="40">
				<input id="wgName" readonly="readonly" onclick="showWg(this)" style="width: 200px; height:20px;border: solid 1px #ccc;"/>
				<input id="wgCode" type="hidden"/>
			</td>
		</tr>
		<tr>
			<td colspan="4" align="center" height="40">
				<input id="btn_cx" type="button" value="查询" style="background: #06a0ef; border: medium none; color: #fff; height: 30px; margin-left: 20px; outline: medium none; width: 100px;"/>
	    		<input id="btn_czh" type="button" value="重置"   style="background: #06a0ef; border: medium none; color: #fff; height: 30px; margin-left: 20px; outline: medium none; width: 100px;"/>
	    	</td>
		</tr>
	</table>
	
	<div id="sydwGrid"></div>
	
	<script type="text/javascript">
	$(function(){
		$("#sydwGrid").flexigrid({
			title:"使用单位信息",
			url:'<c:url value='/sydw/dataGrid'/>',
			colModel:[
				{display: "组织机构代码", name: "zzjgdm"},
				{display: "单位名称", name: "qymc"},
				{display: "所属辖区", name: "ssxq"},
				{display: "所属网格", name: "sswg"},
				{display: "详细地址", name: "dz"},
				{display: "电梯数量", name: "dtsl"},
				{display: "联系方式", name: "lxrlxfs"}
			],
			buttons:[
				{name: "新增", bclass: "add", onpress: btns},
				{separator: true},
				{name: "修改", bclass: "modify", onpress: btns},          
				{separator: true},
				{name: "删除", bclass: "delete", onpress: btns},
				{separator: true}
			],
			usepager: true
		});
		
		//查询
		$("#btn_cx").click(function() {
			$("#sydwGrid").flexOptions({
				newp : 1,
				params : [ 
				           {name : 'sydwQymc', value : encodeURI($("#sydwQymc").val())},
				           {name : 'sydwZzjgdm', value : $("#sydwZzjgdm").val()},
				           {name : 'sydwQhdm', value : $("#xzqhCode").val()},
				           {name : 'sydwWgqygsId', value : $("#wgCode").val()}
						]
			}).flexReload();
		});
		
		//重置
		$("#btn_czh").click(function() {
			$("#sydwQymc").val("");
			$("#sydwZzjgdm").val("");
			$("#xzqhName").val("");
			$("#xzqhCode").val("");
			$("#wgName").val("");
			$("#wgCode").val("");
		});
	});
	
	function btns(com,grid){
		if("新增" == com) {
			art.dialog.open(
					"<c:url value='/sydw/fSydw'/>",
					{
						id: "addSydw",
						title: "添加使用单位",
						lock: true,
						width: 700,
						height: 400
					}
				);
		}else if($(".trSelected", grid).length == 1) {
			var id=$('.trSelected', grid).attr("id").replace("row","");
			if("修改" == com) {
				art.dialog.open(
					"<c:url value='/sydw/toUpdate?sydwId="+id+"'/>",
					{
						id: "updateSydw",
						title: "修改使用单位",
						lock: true,
						width: 700,
						height: 400
					}
				);
			}else if("删除" == com) {
				$.post("<c:url value='/sydw/deleteSydw'/>", 
					{ "sydwId": id}, 
					function(json){
						if(json.flag==1){
							$("#sydwGrid").flexReload();
							art.dialog.alert("使用单位删除成功。");
						}else{
							art.dialog.alert("使用单位删除成功。");
						}
				});
			}
		}else {
			art.dialog.alert("请选择要" + com + "的单位！");
		}
	}
	
	//关闭弹出
	function closeAndRefresh(){
		$("#sydwGrid").flexReload();
		$.each(art.dialog.list, function(i, n) {
			art.dialog.list[i].close();
		});
	}
	</script>
	<script type="text/javascript" src="<c:url value="/common/js/zd/xzqh.js"/>" ></script>
	<script type="text/javascript" src="<c:url value="/common/js/zd/wg.js"/>" ></script>
</body>
</html>